
import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;

// 获取下拉选择框中选中项的名称
export const getSelectedName = (options, key) => {
    let name = '';
    for (let i = 0, len = options.length; i < len; i++) {
        if (options[i].key == key) {
            name = options[i].showname;
            break;
        }
    }
    return name;
};

// 日期类型
export const DATE_TYPES = [
    {value: '0', name: getLabel(332,'全部')},
    {value: '1', name: getLabel(15537,'今天')},
    {value: '2', name: getLabel(15539,'本周')},
    {value: '3', name: getLabel(15541,'本月')},
    {value: '4', name: getLabel(21904,'本季')},
    {value: '5', name: getLabel(15384,'本年')},
    {value: '7', name: getLabel(27347,'上个月')},
    {value: '8', name: getLabel(81716,'上一年')},
    {value: '6', name: getLabel(32530,'指定日期范围')}
];

// 获取日期类型名称
export const getDateTypeName = (type) => {
    let name = '';
    for (let i = 0, len = DATE_TYPES.length; i < len; i++) {
        if (DATE_TYPES[i].value == type) {
            name = DATE_TYPES[i].name;
            break;
        }
    }
    return name;
};

// 多选浏览框类型
export const MULTI_BROWSER_TYPE = [17, 18, 37, 57, 65, 135, 152, 162, 166, 168, 170, 184, 194, 257, 278];

// 判断是否是多选浏览框类型
export const isMultiBrowserType = (type) => {
    let isMulti = false;
    for (let i = 0, len = MULTI_BROWSER_TYPE.length; i < len; i++) {
        if (MULTI_BROWSER_TYPE[i] == type) {
            isMulti = true;
            break;
        }
    }
    return isMulti;
};

// 获取单选浏览框类型
export const getSingleBrowserType = (type) => {
    return {17: 1, 18: 7, 37: 9, 57: 4, 65: 267, 135: 8, 152: 16, 162: 161, 166: 165, 168: 167, 170: 169, 184: 87, 194: 164, 257: 256, 278: 24}[type];
};

// 获取多选浏览框类型
export const getMultiBrowserType = (type) => {
    return {1: 17, 7: 18, 9: 37, 4: 57, 267: 65, 8: 135, 16: 152, 161: 162, 165: 166, 167: 168, 169: 170, 87: 184, 164: 194, 256: 257, 24: 278}[type];
};
